<html lang="zh-cn">
<head>
{% include "tdm_include_head_template.html" %}
<script type="text/javascript">
$(function() {
  $("#city_select").change(function() {
    window.location.href="/tdm/admin/acard/"+$("#city_select").val();
  });
  $("#venue_select").change(function() {
    window.location.href="/tdm/admin/acard/"+$("#city_select").val()+"/"+$("#venue_select").val();
  })
});
</script>
</head>

<body class=" theme-blue">
{% include "tdm_include_navbar_template.html" %}

<div class="container">
  <br/>
  {% include "tdm_include_error_template.html" %}

  {% include "tdm_include_admin_page_template.html" %}

  <div class="form-context">
  <form name="venue_form" class="form-horizontal" role="form" action="/tdm/admin/acard/{{view_city.name}}/{{view_venue.name}}/" method="post">
    <div class="row">
      <div class="col-md-3">
        <select name="city_select" id="city_select" class="form-control">
          {% for city in city_all %}
          <option value="{{city.name}}" {% ifequal city.name view_city.name %}selected="selected"{% endifequal %}>{{city.name}}</option>
          {% endfor %}
        </select>
      </div>
      <div class="col-md-3">
        <select name="venue_select" id="venue_select" class="form-control">
          {% for venue in venue_all %}
          <option value="{{venue.name}}" {% ifequal venue.name view_venue.name %}selected="selected"{% endifequal %}>{{venue.name}}</option>
          {% endfor %}
        </select>
        <input type="hidden" name="venue_id" value="{{view_venue.venue_id}}">
      </div>
    </div>
    <br>
    <table id="ctmdev_table" class="table table-hover">
      <tr>
        <th>城市</th>
        <th>教学点</th>
        <th>中控机ID</th>
        <th>备注</th>
        <td>
          <button name="op" value="ctmdev_del" type="submit" class="btn btn-primary btn-sm">删除</button>
        </td>
      </tr>
      {% for ctmdev in ctmdev_all %}
      <tr>
        <td>{{view_city.name}}</td>
        <td>{{view_venue.name}}</td>
        <td class="equidistant">{{ctmdev.devid}}</td>
        <td>{{ctmdev.memo}}</td>
        <td>
          <input type="checkbox" name="ctmdev_list" value="{{ctmdev.devid}}">
        </td>
      </tr>
      {% endfor %}
      <tr>
        <td>
          <label for="city" class="sr-only">城市</label>
          <input name="city" type="text" class="form-control" id="city" value="{{view_city.name}}" readonly>
        </td>
        <td>
          <label for="venue_name" class="sr-only">教学点</label>
          <input name="venue_name" type="text" class="form-control" id="venue_name" value="{{view_venue.name}}" readonly>
        </td>
        <td>
          <label for="ctmdev_id" class="sr-only">中控机ID</label>
          <input name="ctmdev_id" type="text" class="form-control" id="ctmdev_id" placeholder="中控机ID">
        </td>
        <td>
          <label for="ctmdev_memo" class="sr-only">备注</label>
          <input name="ctmdev_memo" type="text" class="form-control" id="ctmdev_memo" placeholder="备注">
        </td>
        <td><button name="op" value="ctmdev_add" type="submit" class="btn btn-primary btn-sm">添加</button></td>
      </tr>
    </table>
    <table id="cardreader_table" class="table table-hover">
      <tr>
        <th>城市</th>
        <th>教学点</th>
        <th>读卡器ID</th>
        <th>备注</th>
        <td><button name="op" value="cardreader_del" type="submit" class="btn btn-primary btn-sm">删除</button></td>
      </tr>
      {% for cardreader in cardreader_all %}
      <tr>
        <td>{{view_city.name}}</td>
        <td>{{view_venue.name}}
        <td>{{cardreader.ip}}</td>
        <td>{{cardreader.memo}}</td>
        <td><input type="checkbox" name="cardreader_list" value="{{cardreader.ip}}"></td>
      </tr>
      {% endfor %}
      <tr>
        <td>
          <label for="city" class="sr-only">城市</label>
          <input name="city" type="text" class="form-control" id="city" value="{{view_city.name}}" readonly>
        </td>
        <td>
          <label for="venue_name" class="sr-only">教学点</label>
          <input name="venue_name" type="text" class="form-control" id="venue_name" value="{{view_venue.name}}" readonly>
        </td>
        <td>
          <label for="cardreader_ip" class="sr-only">读卡器IP</label>
          <input name="cardreader_ip" type="text" class="form-control" id="cardreader_ip" placeholder="读卡器ID">
        </td>
        <td>
          <label for="cardreader_memo" class="sr-only">备注</label>
          <input name="cardreader_memo" type="text" class="form-control" id="cardreader_memo" placeholder="备注">
        </td>
        <td><button name="op" value="cardreader_add" type="submit" class="btn btn-primary btn-sm">添加</button></td>
      </tr>
    </table>
  </form>
  </div>

{% include "tdm_include_footer_template.html" %}
</div>
</body>
</html>